load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
load("//:gen_test_targets.bzl", "gen_test_targets")

cc_library(
    name = "avro_cpp",
    srcs = glob(
        [
            "impl/**/*.cc",
            "impl/**/*.hh",
        ],
        # This is a binary and not part of the library.
        exclude = ["impl/avrogencpp.cc"],
    ),
    hdrs = glob(["include/**/*.hh"]),
    includes = [
        "include",
        "include/avro",
    ],
    visibility = ["//visibility:public"],
    deps = [
        "@boost.algorithm",
        "@boost.crc",
        "@boost.filesystem",
        "@boost.iostreams",
        "@boost.math",
        "@boost.program_options",
        "@boost.regex",
        "@boost.system",
        "@fmt",
    ],
)

alias(
    name = "avro-cpp",
    actual = ":avro_cpp",
    visibility = ["//visibility:public"],
)

cc_binary(
    name = "avrogencpp",
    srcs = ["impl/avrogencpp.cc"],
    visibility = ["//visibility:public"],
    deps = [
        ":avro_cpp",
        "@boost.algorithm",
        "@boost.lexical_cast",
        "@boost.program_options",
        "@boost.random",
    ],
)

gen_test_targets(
    name = "gen_avro_cpp_test_targets",
    cc_srcs = glob(
        ["test/*.cc"],
        exclude = [
            # These tests require generating header files from the JSON schema
            # files using avrogencpp.
            "test/AvrogencppTestReservedWords.cc",
            "test/AvrogencppTests.cc",
            "test/testgentest.cc",
            # This test passes but fails with a pointer error.
            "test/CommonsSchemasTests.cc",
            "test/CompilerTests.cc",
            "test/JsonTests.cc",
            "test/SpecificTests.cc",
            # These look like binaries rather than unit tests as they require
            # reading from stdin.
            "test/precompile.cc",
            "test/testparser.cc",
            # Requires usage of runfiles lib to locate the jsonschema file
            # passed in.
            "test/LargeSchemaTests.cc",
        ],
    ),
)
